package cn.lopr.sccs;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @author shuangyang7
 * @date 2020/11/25 13:29
 */
public class ResourceHelper {

    public ResourceHelper() {
    }

    public static Properties load(String name) {
        String path = "/" + name + ".properties";

        try {
            InputStream in = ResourceHelper.class.getResourceAsStream(path);

            Throwable throwable = null;
            Properties result = new Properties();
            try {

                if (in == null) {
                    return null;
                }
                Properties properties = new Properties();

                properties.load(in);

                result = properties;

            } catch (Throwable t) {
                throwable = t;
                throw t;
            } finally {
                if (in != null) {
                    if (throwable != null) {
                        try {
                            in.close();
                        } catch (Throwable var15) {
                            throwable.addSuppressed(var15);
                        }
                    } else {
                        in.close();
                    }
                }
            }

            return result;
        } catch (IOException e) {
            e.printStackTrace();

            return null;
        }
    }
}
